from rest_framework import serializers
from goods.models import SPUSpecification, SpecificationOption


class SPUSpecificationSerializer(serializers.ModelSerializer):
    """ 商品SPU规格 模型类序列化器 """

    spu = serializers.StringRelatedField(read_only=True)
    spu_id = serializers.IntegerField()

    class Meta:
        model = SPUSpecification
        fields = ["id", "name", "spu", "spu_id"]


class SpecificationOptionSerializer(serializers.ModelSerializer):
    """ 规格选项 模型类序列化表 """

    spec = serializers.StringRelatedField(read_only=True)
    spec_id = serializers.IntegerField()

    class Meta:
        model = SpecificationOption
        fields = ["id", "value", "spec", "spec_id"]

